package com.healthySys.common.utils;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.healthySys.common.result.Result;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

public class ResponseUtils {

    public static void writeJsonResponse(HttpServletResponse response, int status, int code, String message) throws IOException {
        response.setContentType("application/json;charset=UTF-8");
        response.setStatus(status);
        
        String json = new ObjectMapper().writeValueAsString(
            new Result<>(code, message, null)
        );
        
        response.getWriter().write(json);
    }
}